package socket_study;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.UnknownHostException;

public class SocketDemo1 {
    public static void main(String[] args) throws Exception {
//        InetAddress host = InetAddress.getLocalHost();
//        String ip =host.getHostAddress();
//        System.out.println("本机ip地址：" + ip);
    	Process p = Runtime.getRuntime().exec("ping "+"192.168.234.100");
    	//InputStreamReader isr = new InputStreamReader(new FileInputStream(
       // file), sourceCharset);  通过这样设置编码
    	BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream(),"GBK"));
    	String line =null;
    	StringBuilder sb = new StringBuilder();
    	while((line = br.readLine())!=null){
    		if(line.length()!=0){
    			sb.append(line+"\r\n");
    			
    		}
    		System.out.println("执行ping  192.168.234.100返回："+sb.toString());
    	}
    }
}
